package com.smart.campus.controller;

import com.smart.campus.dto.ProtectiveGuidanceManagement;
import com.smart.campus.dto.ShAttendanceDetails;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.pojo.ResponseResult;
import com.smart.campus.service.ShAttendanceDetailsFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.controller
 * @Author: 戴冰洁
 * @CreateTime: 2024-10-07  19:45
 * @Description: TODO
 * @Version: 1.0
 */
@Api(tags = "学生考勤模块")
@Slf4j
@RestController
@RequestMapping(value = "attend")
public class ShAttendanceDetailsController {
    @Autowired
    private ShAttendanceDetailsFeign shAttendanceDetailsFeign;
    @ApiOperation(value = "学生考勤查询", httpMethod = "GET", notes = "学生考勤查询")
    @RequestMapping(value = "findattendlist")
    public ResponseResult<List<ShAttendanceDetails>> findattendlist(){
        return new ResponseResult<>(200,"查询成功",shAttendanceDetailsFeign.findattendlist());
    }
    @ApiOperation(value = "学生考勤新增",httpMethod = "POST",notes = "学生考勤新增")
    @RequestMapping(value = "addattend")
    public ResponseResult addattend(@RequestBody ShAttendanceDetails shAttendanceDetails){
        try {
            shAttendanceDetailsFeign.addattend(shAttendanceDetails);
            return new ResponseResult(200,"新增成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"新增失败");
        }
    }
    @ApiOperation(value = "删除信息", httpMethod = "GET", notes = "删除信息")
    @RequestMapping(value = "daleteattend")
    public ResponseResult daleteattend(@RequestParam(value = "id") Integer id){
        try {
            shAttendanceDetailsFeign.daleteattend(id);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"删除失败");
        }
    }
    @ApiOperation(value = "学生考勤分页查询",httpMethod = "POST",notes = "学生考勤分页查询")
    @RequestMapping(value = "attendById")
    public ResponseResult<PagedResponse<ShAttendanceDetails>> attendById(@RequestBody ShAttendanceDetails shAttendanceDetails, @RequestParam(value = "pageSum")Integer pageSum, @RequestParam(value = "pageSize")Integer pageSize){
        return new ResponseResult<>(200,"分页查询成功",shAttendanceDetailsFeign.attendById(shAttendanceDetails,pageSum,pageSize));
    }
    @ApiOperation(value = "学生考勤信息回显",httpMethod = "POST",notes = "学生考勤信息回显")
    @RequestMapping(value = "attenList")
    public ResponseResult<ShAttendanceDetails> attenList(Integer id){
        return new ResponseResult<>(200,"回显成功",shAttendanceDetailsFeign.attenList(id));
    }
    @ApiOperation(value = "修改信息", httpMethod = "POST", notes = "修改信息")
    @RequestMapping(value = "updateattend")
    public ResponseResult updateattend(@RequestBody ShAttendanceDetails shAttendanceDetails){
        try {
            shAttendanceDetailsFeign.updateattend(shAttendanceDetails);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"修改失败");
        }
    }
}
